/**
 * Routes 路由配置
 */
const routes = [
    // 登录
    {
        path: 'userLogin(/:status)',
        getComponent(nextState, cb) {
            require.ensure([], (require) => {
                cb(null, require('../view/userLogin').default);
            }, 'userLogin');
        }
    },
    {
        component: require('../view/layouts').default,
        childRoutes: [
            {
                path: '/',
                indexRoute: {
                    onEnter: (nextState, replace) => {
                        const token = sessionStorage.getItem('token');
                        if(!token){
                            replace('userLogin')
                        }else{
                            replace('inforMation')
                        }
                        
                    }
                },
            },
            {
                path: '/home',
                getComponent(nextState, cb) {
                    require.ensure([], (require) => {
                        cb(null, require('../view/home').default);
                    }, 'inforMation');
                },
            },
            {
                // inforMation
                path: '/inforMation',
                breadcrumbName: '信息列表',
                getComponent(nextState, cb) {
                    require.ensure([], (require) => {
                        cb(null, require('../view/inforMation').default);
                    }, 'inforMation');
                },
                indexRoute: {
                    // onEnter: (nextState, replace) => replace('system/accountManage/home'),
                },
            },
        ],
    },
    // 错误页面
    {
        path: 'error',
        getComponent(nextState, cb) {
        require.ensure([], (require) => {
            cb(null, require('../view/error').default);
        }, 'error');
        },
    },
    // 404
    {
        path: '*',
        getComponent(nextState, cb) {
        require.ensure([], (require) => {
            cb(null, require('../view/404').default);
        });
        },
    },
];

export default routes;
